package com.kzw.misc.freemarker;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.kzw.misc.freemarker.tags.ComboDirective;
import com.kzw.misc.freemarker.tags.DictionaryDirective;
import com.kzw.misc.freemarker.tags.GrantDirective;

import freemarker.template.Configuration;
import freemarker.template.TemplateModelException;

@Component
public class FreemarkerConfig {

	@Autowired
	private Configuration configuration;
	@Autowired
	private DictionaryDirective dictDirective;
	@Autowired
	private GrantDirective grantDirective;
	@Autowired
	private ComboDirective comboDirective;
	
	@PostConstruct
	public void setSharedVariable() throws TemplateModelException {
		configuration.setSharedVariable("dicts", dictDirective);
		configuration.setSharedVariable("grant", grantDirective);
		configuration.setSharedVariable("combo", comboDirective);
	}
}
